﻿@*
    For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = "~/Areas/SysAdmin/Views/Shared/_Layout.cshtml";
}
@section styles{
    <link href="/css/plugins/jqgrid/ui.jqgridffe4.css?0820" rel="stylesheet">
    <style>
        /* Additional style to fix warning dialog position */

        #alertmod_table_list_2 {
            top: 900px !important;
        }
    </style>
}
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox ">
                <div class="ibox-title">
                    <h5>分类列表</h5>
                </div>
                <div class="ibox-content">

                    <h4 class="m-t"><a href="/sysadmin/ArticleCategory/Add">添加分类</a></h4>

                    <div class="jqGrid_wrapper">
                        <table id="jqGrid"></table>
                        <div id="pagerlist"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script src="/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="/js/plugins/jqgrid/i18n/grid.locale-cnffe4.js?0820"></script>
    <script src="/js/plugins/jqgrid/jquery.jqGrid.minffe4.js?0820"></script>
    <script src="/js/content.min.js?v=1.0.0"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $.jgrid.defaults.styleUI = "Bootstrap";
            $("#jqGrid").jqGrid({
                 url : '/sysadmin/articlecategory/indexdata',
                 datatype : "json",
                colNames: ["序号", "名字", "标题", "是否为图文", "添加时间", "操作", ],
                colModel: [
                    { name: "id", index: "id", editable: true, width: 60, sorttype: "int", search: true },
                    { name: "name", index: "name", editable: true, width: 90 },
                    { name: "title", index: "title", editable: true, width: 100 },
                    { name: "isAlbums", index: "isAlbums", editable: true, width: 80, align: "right", formatter: formatisAlbums },
                    { name: "addTime", index: "addTime", editable: true, width: 80, align: "right", sorttype: "date", formatter: "date" },
                    { name: "id", index: "id", editable: true, width: 80, align: "right", formatter: formatOperation }],
                viewrecords: true, // show the current page, data rang and total records on the toolbar
                width: 780,
                height: 600,
                 rowNum : 15,
        rowList : [ 10, 15, 20 ],
        pager : '#pagerlist',
          width: 780,
          height: 600,
      //  sortname : 'id',
        viewrecords : true,
     //   sortorder : "desc",

      }).navGrid("#pagerlist", {edit : false,add : false,del : false});
var width = $(".jqGrid_wrapper").width(); $("#jqGrid").setGridWidth(width) 




            function formatOperation(cellValue, options, rowObject) {
                return "<a href='/sysadmin/ArticleCategory/edit/" + cellValue + "'>编辑</a>";
            };
            function formatisAlbums(cellValue, options, rowObject) {
                if (cellValue)
                    return "是";
                else
                    return "否";
            };

            function formatTitle(cellValue, options, rowObject) {
                return cellValue.substring(0, 50) + "...";
            };

            function formatLink(cellValue, options, rowObject) {
                return "<a href='" + cellValue + "'>" + cellValue.substring(0, 25) + "..." + "</a>";
            };

            $("#jqGrid").setSelection(4, true);
            $('#jqGrid').navGrid('#pagerlist',
                   // the buttons to appear on the toolbar of the grid
                   { edit: false, add: false, del: true, search: false, refresh: false, view: false, position: "left", cloneToTop: false },
                   // options for the Edit Dialog
                   {

                       errorTextFormat: function (data) {
                           return 'Error: ' + data.responseText
                       }
                   },
                   // options for the Add Dialog
                   {

                       errorTextFormat: function (data) {
                           return 'Error: ' + data.responseText
                       }
                   },
                   // options for the Delete Dailog
                   {
                       url: "/sysadmin/ArticleCategory/del",
                       errorTextFormat: function (data) {
                           return 'Error: ' + data.responseText
                       }
                   });

            $(window).bind("resize", function () { var width = $(".jqGrid_wrapper").width(); $("#jqGrid").setGridWidth(width) })

        });

    </script>


}
